package work20241203_chap6oop.k_demo9;

import com.sun.org.apache.bcel.internal.generic.ARETURN;

import java.util.Arrays;

/**
 * @author zdl
 * @date 2024/12/3
 */
public class Team {
    private Role[] roles;
    private int count;

    public Team() {
        roles = new Role[6];
        count = 0;
    }
    //添加成员
    public boolean addMember(Role role){
        if (count < 6){
            roles[count] = role;
            count++;
            return true;
        }else {
            System.out.println("队伍已满");
            return false;
        }
    }
    //计算伤害
    public int attackSum(){
        int num = 0;
        for (int i = 0; i < count; i++) {
            num += roles[i].attack();
        }
        return num;
    }

}
